package web.api.global.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import web.api.global.interceptor.LoginInterceptor;

/**
 * @author Jin Zheng
 * @since 2022-01-07
 */
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

	private LoginInterceptor loginInterceptor;

	public WebMvcConfig() {
	}

	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		registry.addInterceptor(loginInterceptor)
				.addPathPatterns("/**");
	}

	@Autowired
	public void setLoginInterceptor(LoginInterceptor loginInterceptor) {
		this.loginInterceptor = loginInterceptor;
	}
}
